using System;
using System.IO;
using System.Collections.Generic;
using System.Reflection;
using System.Text;
using System.Xml;
using System.Xml.Serialization;

namespace stsdev {

  public class TargetsBuilder {

    public static void Create(string FilePath) {
      FileStream stream = new FileStream(FilePath, FileMode.Create, FileAccess.Write);
      StreamWriter writer = new StreamWriter(stream);
      string TargetFileContents = Properties.Resources.Microsoft_SharePoint_targets;

      TargetFileContents = TargetFileContents.Replace("@ProjectName", SolutionBuilder.SolutionName);
      TargetFileContents = TargetFileContents.Replace("@DeploymentFilesFolder", Properties.Resources.DeploymentFilesFolder);
      TargetFileContents = TargetFileContents.Replace("@RootFilesFolder", Properties.Resources.RootFilesFolder);
      //TargetFileContents = TargetFileContents.Replace("@StsDevPath", Assembly.GetExecutingAssembly().Location);

      TargetFileContents = TargetFileContents.Replace("@StsAdmDeployParameters", SolutionBuilder.StsAdmDeployParameters);
      TargetFileContents = TargetFileContents.Replace("@StsAdmUpgradeParameters", SolutionBuilder.StsAdmUpgradeParameters);
      TargetFileContents = TargetFileContents.Replace("@StsAdmRetractParameters", SolutionBuilder.StsAdmRetractParameters);

      writer.Write(TargetFileContents);
      writer.Dispose();
      stream.Dispose();
    }
  }
}
